package com.example.jetpacktest.room.dao

import androidx.room.*
import com.example.jetpacktest.room.bean.Employee
import com.example.jetpacktest.room.bean.EmployeeDepartmentInfo
import kotlinx.coroutines.flow.Flow

@Dao
interface EmployeeDao {

    @Insert
    fun addEmployee(vararg employee: Employee)

    @Delete
    fun deleteEmployee(vararg employee: Employee)

    @Update
    fun updateEmployee(vararg employee: Employee)

    @Query("select e.name as employeeName, e.age, e.salary, d.name as departmentName  from employee as e inner join department as d on e.department_id = d.id")
    fun getAllEmployeeDepartmentInfos(): List<EmployeeDepartmentInfo>

    @Query("select * from employee")
    fun getAllEmployees(): List<Employee>

    @Query("select * from employee")
    fun realTimeGetAllEmployees(): Flow<List<Employee>>


}